﻿using Hvam.SharePoint.Search.Language.Parsers;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hvam.SharePoint.Search.Tests.Internal.Language.Parsers
{
    [TestClass]
    public class ParserExtensionsTests
    {
        [TestMethod]
        public void ParserExtensionsOrTest()
        {
            // Arrange
            const string input = "b";

            var parser =
                from c in 
                       CharParser.Char('a').
                    Or(CharParser.Char('b'))
                select c;

            // Act
            var result = parser.Parse(input);

            // Assert
            Assert.AreEqual('b', result);
        }

        [TestMethod]
        public void ParserExtensionsOrTestC()
        {
            // Arrange
            const string input = "c";

            var parser =
                from c in 
                       CharParser.Char('a').
                    Or(CharParser.Char('b')).
                    Or(CharParser.Char('c'))
                select c;

            // Act
            var result = parser.Parse(input);

            // Assert
            Assert.AreEqual('c', result);
        }
    }
}
